<?php

class Rnaasv_User implements Zend_Acl_Role_Interface {
	
	protected $_user;
	
	function __construct(stdClass $user) {
		$this->_user = $user;
	}
	
	public function getUserObject() {
		return $this->_user;
	}
	
	public function __get($name) {
		return $this->_user->{$name};
	}
	
	public function getRoleId() {
		$roleId = "con_sesion";
		if ($this->isAdulto ()) {
			$roleId = "adulto";
			if ($this->isAdultoGrupo () && $this->isAdultoInstitucional ()) {
				$roleId = "institucional_grupo";
			} elseif ($this->isAdultoGrupo ()) {
				$roleId = "grupo";
			} elseif ($this->isAdultoInstitucional ()) {
				$roleId = "institucional";
			}
		} else {
			for($i = 0; $i < sizeof ( $this->roles ); $i ++) {
				$role = $this->roles [$i];
				$roleId = $role->getRoleId();
			}
		}
		return $roleId;
	}
	
	public function isJoven() {
		for($i = 0; $i < sizeof ( $this->roles ); $i ++) {
			$role = $this->roles [$i];
			if ($role->isJoven ()) {
				return true;
			}
		}
		return false;
	}
	
	public function isAdulto() {
		for($i = 0; $i < sizeof ( $this->roles ); $i ++) {
			$role = $this->roles [$i];
			if ($role->isAdulto ()) {
				return true;
			}
		}
		return false;
	}
	
	public function isAdultoInstitucional() {
		if ($this->isAdulto ()) {
			for($i = 0; $i < sizeof ( $this->roles ); $i ++) {
				$role = $this->roles [$i];
				if ($role->isAdultoInstitucional ()) {
					return true;
				}
			}
		} else {
			return false;
		}
		return false;
	}
	
	public function isAdultoGrupo() {
		if ($this->isAdulto ()) {
			for($i = 0; $i < sizeof ( $this->roles ); $i ++) {
				$role = $this->roles [$i];
				if ($role->isAdultoGrupo ()) {
					return true;
				}
			}
		} else {
			return false;
		}
		return false;
	}
	
	public function isLobato() {
		for($i = 0; $i < sizeof ( $this->roles ); $i ++) {
			$role = $this->roles [$i];
			if ($role->isLobato ()) {
				return true;
			}
		}
		return false;
	}
	
	public function isScout() {
		for($i = 0; $i < sizeof ( $this->roles ); $i ++) {
			$role = $this->roles [$i];
			if ($role->isScout ()) {
				return true;
			}
		}
		return false;
	}
	
	public function isRover() {
		for($i = 0; $i < sizeof ( $this->roles ); $i ++) {
			$role = $this->roles [$i];
			if ($role->isRover ()) {
				return true;
			}
		}
		return false;
	}
}

?>
